/*****************************************************************************
Copyright 2006 Kervin L. Pierre
    EMAIL: otlkcon@adevsoft.com

This file is part of Otlkcon.

Otlkcon is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

Otlkcon is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Lesser GNU General Public License for more details.

You should have received a copy of the Lesser GNU General Public License
along with Otlkcon; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*******************************************************************************/


#pragma once

#include <string>

using namespace std;

#include <mapispi.h>

//! Key info for entryIds.
typedef struct O_ENTRYID_KEY_
{
    MAPIUID     instanceGuid;
    MAPIUID     typeGuid;
} O_ENTRYID_KEY;

//! Main identifying key for objects in this message store
//! INFO:  If the size of this object is modified, then
//!        all stored entryIDs will be invalidated.
typedef struct O_ENTRYID_
{
    BYTE        abFlags[4];
    
	//! Store record key (PR_STORE_RECORD_KEY)
	MAPIUID     storeInstanceGuid;
	
	//! For store EntryID is the same as storeInstanceGuid since 
	//! Since Store object is only object
    MAPIUID     instanceGuid;
    MAPIUID     typeGuid;
    
    //! Types as defined by MAPI
    int         typeID;
    
    //! Types as defined internally
    int         supportedInterfaces; 
    
    //! Types as defined internally
    int         primarySupportedInterface; 

    //! Long-term or short-term
    short       entryIDType;

    ULONG       dataSize;
    BYTE        data[1];
} O_ENTRYID;

struct otlkcon_entryid_less
{
    bool operator()( const O_ENTRYID *id1, const O_ENTRYID *id2) const
    {
        int res1;
        int res2;

        res1 = memcmp(&(id1->instanceGuid), &(id2->instanceGuid), sizeof(MAPIUID));
        res2 = memcmp(&(id1->typeGuid), &(id2->typeGuid), sizeof(MAPIUID));

        if(    ( res1 < 0 )
            || ( res1 == 0 && res2 < 0 ) )
            return true;
        else return false;
    }
};

// Interface bit field
#define OTLKCON_IUNKNOWN_CLASS          1
#define OTLKCON_IMAPIPROP_CLASS         2
#define OTLKCON_IMAPICONTAINER_CLASS    4
#define OTLKCON_IMAPIFOLDER_CLASS       8
#define OTLKCON_IMSGSTORE_CLASS         16
#define OTLKCON_IMAPITABLE_CLASS        32
#define OTLKCON_IMESSAGE_CLASS          64
#define OTLKCON_IMSLOGON_CLASS          128
#define OTLKCON_IATTACHMENT_CLASS       256
#define OTLKCON_IXPLOGON_CLASS          512
#define OTLKCON_IXPLOGONACCOUNT_CLASS   1024
#define OTLKCON_IXPPROVIDER_CLASS       2048
#define OTLKCON_IABPMSGSTORE_CLASS      4096
#define OTLKCON_IXPPMSGSTORE_CLASS      8192
#define OTLKCON_IMSPMSGSTORE_CLASS      16384

#define OTLKCON_ENTRYID_VALIDATE_SIZE   1
#define OTLKCON_ENTRYID_VALIDATE_EXISTS 2
#define OTLKCON_ENTRYID_VALIDATE_INTERFACES   4

